<template>
  <div class="activity-item" @click="goBuss">
    <div class="pic">
      <img :src="img_url" alt="" />
    </div>
    <div class="description">
      <h3 class="title">{{ title }}</h3>
      <div class="time-view-count">
        <span class="time">{{ time }}</span>
        <span class="point">·</span>
        <span class="count">{{ getCount(view_count) }}人看过</span>
      </div>
      <div class="address">{{ address }}</div>
    </div>
  </div>
</template>

<script>
export default {
  props: {
    img_url: String,
    title: String,
    address: String,
    time: String,
    view_count: Number,
    id: Number
  },
  methods: {
    getCount(count) {
      if (count < 10000) {
        return count
      } else {
        const re = /^\d+\.?\d?/
        let res = count / 10000 + ''
        return parseFloat(res.match(re)) + '万'
      }
    },
    goBuss() {
      console.log(111)
      this.$router.push('/feeds/' + this.id)
    }
  }
}
</script>

<style lang="less" scoped>
.activity-item {
  display: flex;
  align-items: center;
  margin-bottom: 10px;

  .pic {
    overflow: hidden;
    height: 80px;
    width: 80px;

    img {
      border-radius: 5px;
      height: 100%;
      width: 100%;
    }
  }
  .description {
    margin-left: 5px;
    color: #9b9b9b;
    flex: 1;

    .title {
      font-size: 14px;
      color: #5c5c5c;
      font-weight: 700;
      line-height: 24px;
      white-space: nowrap;
      overflow: hidden;
      max-width: 270px;
      text-overflow: ellipsis;
    }
    .time-view-count {
      display: flex;
      font-size: 12px;
      line-height: 20px;

      .point {
        font-size: 18px;
        padding: 0 2px;
        font-weight: 700;
      }
    }
    .address {
      line-height: 20px;
      font-size: 12px;
    }
  }
}
</style>
